package com.example.demo.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.*;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.util.Date;

@DynamicInsert
@DynamicUpdate
@Entity
@Table(name = "t_user")
@Getter
@Setter
@ToString
@AllArgsConstructor
@NoArgsConstructor
public class User {

    @Id
    @Column(name = "id", nullable = false, unique = true)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @Column(name = "userId", unique = true, nullable = false, length = 128)
    private String userId;

    @Column(name = "loginName", unique = true, nullable = false, length = 100)
    private String loginName;

    @Column(name = "password", length = 128)
    private String password;

    @Column(name = "userName", length = 100)
    private String userName;

    @Column(name = "areaCode", length = 19)
    private Long areaCode;

    @Column(name = "gender")
    private Integer gender;

    @Column(name = "status")
    private Integer status;

    @Column(name = "roleId")
    private Integer roleId;

    @Column(name = "descr", length = 200)
    private String descr;

    @Column(name = "createTime")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;
}
